package com.aletto.general_store.ui.activities;

import android.os.Bundle;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import me.jessyan.autosize.utils.AutoSizeUtils;

import com.aletto.general_store.R;
import com.aletto.general_store.data.entities.WalletAccount;
import com.aletto.general_store.utils.LocalConfigStore;
import com.aletto.general_store.utils.XHelper;
import com.king.zxing.util.CodeUtils;

/**
 * 收款二维码
 */
public class WalletReceiveActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_wallet_receive);
        XHelper.initTitle(this, R.string.title_wallet_receive);

        ImageView receiveImage = findViewById(R.id.wallet_receive_image);
        TextView walletAddressText = findViewById(R.id.tv_wallet_address);

        receiveImage.setImageBitmap(CodeUtils.createQRCode(
                "content", AutoSizeUtils.dp2px(this, 185)));

        findViewById(R.id.copy_address_button).setOnClickListener(v ->
                XHelper.copy2Clipboard(walletAddressText.getText()));

        WalletAccount wallet = LocalConfigStore.getInstance().getWallet();
        walletAddressText.setText(wallet.getAddress());
    }

}
